package summerprojectFX.parser;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.poi.POITextExtractor;
import org.apache.poi.extractor.ExtractorFactory;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;

import summerprojectFX.model.Song;


public class DOCXFile extends FileInputOutput {

	public DOCXFile(File file) {
		super(file);
	}

	public Song read() {
		Song newSong = new Song();
		try {
                                                        FileInputStream fis = new FileInputStream(file.getAbsoluteFile()); 



			XWPFDocument docx = new XWPFDocument(fis);  
		
			XWPFWordExtractor wx = new XWPFWordExtractor(docx);  
			
			newSong = createSong(wx.getText());
			
		} catch (Exception e) {
			System.out.println(e +  " " + file.getAbsoluteFile());
		}

		return newSong;
	}

}
